<?php
class ControllerModuleThongketruycap extends Controller
{
	public function index()
	{
		$this->load->model("core/media");
		$this->getHitCounter();
		$this->getOnline();
		$this->id="module_thongketruycap";
		$this->template="module/thongketruycap.tpl";
		$this->render();
	}
	
	function getHitCounter()
	{
		$this->data['hitcouter'] = (int)@$this->model_core_media->getInformation("hitcounter", "hitcounter");
		if(!isset($_SESSION['hitconter']))
		{
			$this->data['hitcouter']++;
			$this->model_core_media->saveInformation("hitcounter", hitcounter, $this->data['hitcouter']);
			$_SESSION['hitconter'] = $this->data['hitcouter'];
		}
	}
	
	function getOnline()
	{
		$this->load->model("core/online");
		$min_online="1";
		if ($HTTP_X_FORWARDED_FOR == "") 	
		{
			$ip = getenv(REMOTE_ADDR);
		}
		else
		{
			$ip = getenv(HTTP_X_FORWARDED_FOR);
		}
		$this->model_core_online->countOnline();
		$data['online'] = "";
		$data['ip'] = $ip;
		$data['onlinetime'] = $this->date->getToday();
		$this->model_core_online->insert($data);
		//$this->model_core_online->exportListBlackIP();
		$_SESSION['online']=$this->model_core_online->OnlineID;
		//echo $dt->addminutes($dt->_getNow('-'),-20);
		$this->data['online']=$this->model_core_online->countOnline();
	}
}
?>